﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpenseSystem.Model;
using ExpenseSystem.Fether;
using ExpenseSystem.DataUpdater;
using ExpenseSystem.Common;
using ExpenseSystem.DataUpdater.Validation;

namespace ExpenseSystem.Core.ProductionModules
{
    public class SuiteDetailUpdaterRegister
    {
        public NormalDataUpdater<SuiteDetailModel> GetSuiteDetailUpdater()
        {
            NormalDataUpdater<SuiteDetailModel> systemDataUpdater = new NormalDataUpdater<SuiteDetailModel>();
            systemDataUpdater.DataUpdating += DataNotSpaceValid;
            systemDataUpdater.DataUpdating += SingletonValid;
            systemDataUpdater.DataDeleting += CheckAvaliable;
            return systemDataUpdater;
        }
        private void CheckAvaliable(object sender, DataValidationEventArgs<SuiteDetailModel> e)
        {
            if (e.Delete.Avaliable)
            {
                e.Cancle = true;
                e.Message = String.Format("[{0}]正在生效，不能删除", e.Delete.AutoId);
            }
        }

        private void SingletonValid(object sender, DataValidationEventArgs<SuiteDetailModel> e)
        {

        }

        private void DataNotSpaceValid(object sender, DataValidationEventArgs<SuiteDetailModel> e)
        {

        }
       
    }
}
